package com.liuwei.netty.packet;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;

import java.nio.charset.StandardCharsets;

@Slf4j
public class NettyMessageServerHandler extends SimpleChannelInboundHandler<MessageProtocol> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, MessageProtocol msg) throws Exception {
        log.info("---服务器收到的数据---");
        log.info("消息的长度:" + msg.getLength());
        log.info("消息的内容:" + new String(msg.getContent() , StandardCharsets.UTF_8));

    }
}
